<template>
	<view>
		<u-popup :show="showSpecPicker" :round="9" closeable mode="bottom" @close="showSpecPicker=false">
			<view class="popup-content">
				<view class="product-content">
					<view class="f-a-start">
						<image src="/static/shop/category.jpeg" mode="aspectFill" class="info-pic"></image>
						<view class="info-right">
							<view class="name ellipsis2">生活超市商品大茶壶一套生</view>
							<view class="price">¥300.00</view>
						</view>
					</view>
					<view class="spec-rows">
						<view class="title">规格</view>
						<view class="spec-list">
							<view class="spec-item actived">30*35*25</view>
							<view class="spec-item">30*35*25</view>
						</view>
					</view>
					<view class="spec-rows num-rows f-c-between">
						<view class="title">选择数量</view>
						<u-number-box v-model="submitData.num" integer bgColor="#ffffff" inputWidth="45"></u-number-box>
					</view>
				</view>

				<view class="popup-footer f-c-between">
					<view class="cart-num">
						<u-badge :value="5" bgColor="#FF5656" max="99" absolute :offset="[-5,-5]"></u-badge>
						<image src="/static/tab/unSelectCart.png" class="icon-cart"></image>
						<view class="label">购物车</view>
					</view>
					<view class="cart-btns f-a-center f-j-end">
						<button class="btn btn-add">加入购物车</button>
						<button v-if="showBuyBtn" class="btn btn-buy" @click="btnSubmit">立即购买</button>
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		name: "productSpec",
		props: {
			showBuyBtn: {
				type: Boolean,
				default: true
			}
		},
		data() {
			return {
				showSpecPicker: false,
				submitData: {
					spec: 1,
					num: 1
				}
			};
		}
	}
</script>

<style lang="scss">
	.popup-content {
		.product-content {
			padding: 66rpx 46rpx 34rpx;

			.info-pic {
				width: 152rpx;
				height: 152rpx;
				display: block;
				border-radius: 10rpx;
				margin-right: 24rpx;
				display: block;
			}

			.info-right {
				flex: 1;
				padding-top: 4rpx;

				.name {
					height: 84rpx;
					font-weight: 500;
					font-size: 32rpx;
					line-height: 42rpx;
					color: #333333;
					margin-bottom: 16rpx;
				}

				.price {
					font-weight: 500;
					font-size: 36rpx;
					color: #EC673F;
				}
			}
		}

		.spec-rows {
			margin-top: 36rpx;

			.title {
				font-weight: 500;
				font-size: 28rpx;
				color: #333333;
			}

			.spec-list {
				padding-top: 14rpx;

				.spec-item {
					font-weight: 400;
					font-size: 32rpx;
					color: #FFC046;
					border-radius: 30rpx;
					border: 2rpx solid #FFC046;
					margin-right: 20rpx;
					padding: 8rpx 28rpx;
					display: inline-block;

					&.actived {
						background: #FFC046;
						color: #FFFFFF;
					}
				}
			}
		}

		.num-rows {
			margin-top: 40rpx;

			/deep/.u-number-box {
				border: 1px solid #cdcdcd;
				border-radius: 16rpx;
			}

			/deep/.u-number-box__minus,
			/deep/.u-number-box__plus {
				width: 30px !important;
				height: 30px !important;
			}

			/deep/.u-number-box__minus {
				border-radius: 16rpx 0 0 16rpx;
				border-right: 1px solid #cdcdcd;
			}

			/deep/.u-number-box__plus {
				border-radius: 0 16rpx 16rpx 0;
				border-left: 1px solid #cdcdcd;
			}

			/deep/.u-number-box__input {
				height: 30px;
				margin: 0;
				border-left: 0;
				border-right: 0;
			}
		}
	}

	.popup-footer {
		padding: 18rpx 22rpx 18rpx 40rpx;
		background-color: #FFFFFF;
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		z-index: 9999;

		.cart-num {
			position: relative;

			/deep/.u-badge {
				z-index: 9;
			}

			.icon-cart {
				width: 54rpx;
				height: 54rpx;
				display: block;
			}

			.label {
				font-weight: 400;
				font-size: 20rpx;
				color: #909090;
				margin-top: 4rpx;
			}
		}

		.cart-btns {
			flex: 1;

			.btn {
				width: 250rpx;
				height: 70rpx;
				background: #FFC046;
				border-radius: 35rpx;
				font-weight: 400;
				font-size: 28rpx;
				color: #FFFFFF;
			}

			.btn-add {
				background: #FFC046;
			}

			.btn-buy {
				background: #FF5656;
				margin-left: 30rpx;
			}
		}
	}
</style>